import logging
import settings


class Logger:

    def __init__(self, file_path, level):
        fh = logging.FileHandler(file_path, 'a', encoding='utf-8')
        fmt = logging.Formatter(fmt='%(asctime)s - %(name)s - %(levelname)s -%(module)s:  %(message)s')
        fh.setFormatter(fmt)

        self.logger = logging.Logger('cmdb', level=level)
        self.logger.addHandler(fh)

    def error(self, msg):
        self.logger.error(msg)

    def info(self, msg):
        self.logger.info(msg)

    def critical(self, msg):
        self.logger.critical(msg)


logger = Logger(settings.LOG_PATH, logging.INFO)
